From 544cc17f45ec1502d3095bc708c0c921e75d7982 Mon Sep 17 00:00:00 2001 From: robertl Date: Mon, 12 Dec 2005 15:43:00 +0000 Subject: [PATCH] Sketch in Yahoo geocode reader. --- gpsbabel/Makefile | 3 +- gpsbabel/vecs.c | 7 ++++ gpsbabel/yahoo.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 gpsbabel/yahoo.c diff --git a/gpsbabel/Makefile b/gpsbabel/Makefile index a39b87997..2adebd792 100644 --- a/gpsbabel/Makefile +++ b/gpsbabel/Makefile @@ -44,7 +44,8 @@ FMTS=magproto.o gpx.o geo.o mapsend.o mapsource.o garmin_tables.o \ igc.o brauniger_iq.o shape.o hiketech.o glogbook.o coastexp.o \ vcf.o overlay.o kml.o google.o lowranceusr.o an1.o tomtom.o \ tef_xml.o maggeo.o pathaway.o vitosmt.o gdb.o bcr.o coto.o \ - ignrando.o stmwpp.o msroute.o cst.o nmn4.o mag_pdb.o compegps.o + ignrando.o stmwpp.o msroute.o cst.o nmn4.o mag_pdb.o compegps.o \ + yahoo.o FILTERS=position.o duplicate.o arcdist.o polygon.o smplrout.o \ reverse_route.o sort.o stackfilter.o trackfilter.o discard.o \ diff --git a/gpsbabel/vecs.c b/gpsbabel/vecs.c index 679b37803..322f2de82 100644 --- a/gpsbabel/vecs.c +++ b/gpsbabel/vecs.c @@ -94,6 +94,7 @@ extern ff_vecs_t cst_vecs; extern ff_vecs_t nmn4_vecs; extern ff_vecs_t magpdb_vecs; extern ff_vecs_t compegps_vecs; +extern ff_vecs_t yahoo_vecs; static vecs_t vec_list[] = { @@ -482,6 +483,12 @@ vecs_t vec_list[] = { "CompeGPS data files (.wpt/.trk/.rte)", NULL }, + { + &yahoo_vecs, + "yahoo", + "Yahoo Geocode API data", + NULL + }, { NULL, NULL, diff --git a/gpsbabel/yahoo.c b/gpsbabel/yahoo.c new file mode 100644 index 000000000..bd808f8c7 --- /dev/null +++ b/gpsbabel/yahoo.c @@ -0,0 +1,102 @@ +/* + Read Yahoo Geocoded files. + + Copyright (C) 2005 Robert Lipe, robertlipe@usa.net + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA + + */ + +#include "defs.h" +#include "xmlgeneric.h" + +static FILE *ifd; +static waypoint *wpt_tmp; + +#define MYNAME "yahoo" + +static +arglist_t yahoo_args[] = { + {0, 0, 0, 0, 0} +}; + +static xg_callback wpt_s, wpt_lat, wpt_lon, wpt_e; + +static xg_tag_mapping gl_map[] = { + { wpt_s, cb_start, "/ResultSet/Result" }, + { wpt_lat, cb_cdata, "/ResultSet/Result/Latitude" }, + { wpt_lon, cb_cdata, "/ResultSet/Result/Longitude" }, + { wpt_e, cb_end, "/ResultSet/Result" }, + { NULL, 0, NULL} +}; + +static void +yahoo_rd_init(const char *fname) +{ + xml_init(fname, gl_map, NULL); +} + +static void +yahoo_read(void) +{ + xml_read(); +} + +static void +yahoo_rd_deinit(void) +{ + xml_deinit(); +} + +static void +yahoo_wr_init(const char *fname) +{ + fatal("Writing file of type %s is not supported\n", MYNAME); +} + +void wpt_s(const char *args, const char **unused) +{ + wpt_tmp = waypt_new(); +} + +void wpt_e(const char *args, const char **unused) +{ + waypt_add(wpt_tmp); + wpt_tmp = NULL; +} + +void wpt_lat(const char *args, const char **unused) +{ + wpt_tmp->latitude = atof(args); +} + +void wpt_lon(const char *args, const char **unused) +{ + wpt_tmp->longitude = atof(args); +} + +ff_vecs_t yahoo_vecs = { + ff_type_file, + { ff_cap_read }, + yahoo_rd_init, + yahoo_wr_init, + yahoo_rd_deinit, + NULL, + yahoo_read, + NULL, + NULL, + yahoo_args, + CET_CHARSET_ASCII, 0 /* CET-REVIEW */ +}; -- 2.30.2